package cn.cdiothree.controller;

import cn.cdiothree.dataobject.ActivityInfo;
import cn.cdiothree.dataobject.MyPageHelper;
import cn.cdiothree.service.ActivityInfoService;
import cn.cdiothree.vo.ActivityInfoVo;
import cn.cdiothree.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 活动详情
 * @author cumthing
 */

@RestController
@RequestMapping("/activity-info")
public class ActivityInfoController {
    @Autowired
    ActivityInfoService activityInfoService;

    /**
     * 查看所有活动
     * @return
     */
    @GetMapping("/list")
    public ResultVo activities(){
        MyPageHelper<ActivityInfoVo> myPageHelper = activityInfoService.getAll(1,2);
        return ResultVo.success(myPageHelper);
    }

    /**
     * 根据活动类目查看活动
     * @param categoryId
     * @return
     */
    @GetMapping("/list2")
    public ResultVo activitiesByCategoryId(Integer categoryId){
        MyPageHelper<ActivityInfoVo> myPageHelper = activityInfoService.getActivityInfoVoListByCategoryId(1,2,categoryId);
        return ResultVo.success(myPageHelper);
    }

    /**
     * 查看活动详情
     * @param activityId
     * @return
     */
    @GetMapping("/detail")
    public ActivityInfo findById(Integer activityId){
        ActivityInfo activityInfo = activityInfoService.findByActivityId(activityId);
        return activityInfo;
    }

    /**
     * 根据组织查看活动
     * @param organizationId
     * @return
     */
    @GetMapping("/organization/list")
    public List<ActivityInfoVo> selectByOrganizationId(Integer organizationId){
        List<ActivityInfoVo> activityInfoVoList = activityInfoService.selectByOrganizationId(organizationId);
        return activityInfoVoList;
    }

}
